import {
  Constant_Enum_Enum_CouponUserClient_Status,
  Constant_Enum_Name_CouponUserClient_Status,
  IConstant_Enum_Type_CouponUserClient_Status,
} from '@/common/constants/enum';
import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Coupon } from '../../coupon/assets/coupon.entity';
import { UserClient } from '../../userClient/assets/userClient.entity';

@Entity('couponuserclient')
export class CouponUserClient {
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '优惠券', type: () => Coupon })
  @ManyToOne(() => Coupon)
  coupon: Coupon;

  @ApiProperty({ description: '用户Id', type: () => UserClient })
  @ManyToOne(() => UserClient, { cascade: ['remove'], onDelete: 'CASCADE' })
  userClient: UserClient;

  @Column({ type: 'bigint' })
  @ApiProperty({ description: '开始时间', type: 'bigint' })
  fixedTimeStart: number;

  @Column({ type: 'bigint' })
  @ApiProperty({ description: '结束时间', type: 'bigint' })
  fixedTimeEnd: number;

  @Column({ default: Constant_Enum_Enum_CouponUserClient_Status.ExCode_ExCodeValue_Use })
  @ApiProperty({
    description: '状态' + Constant_Enum_Name_CouponUserClient_Status,
    enum: Constant_Enum_Enum_CouponUserClient_Status,
  })
  status: IConstant_Enum_Type_CouponUserClient_Status;
}
